/**
 * 
 */
package com.shop.mappers;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.shop.entities.Product;

/**
 * 
 *
 */
public interface ProductMapper {
	
	@Select("select * from product where id=#{id}")
	public Product findProductById(Integer id);
	
	@Select("select * from product where c_id=#{category.id}")
	public List<Product> findProductsByCategoryId(Integer id);
	
	
	@Select("select * from product")
	public List<Product> findAllProducts();
	
	
	@Update("update product set name = #{name},price =#{price},quantity=#{quantity}, description = #{description}, c_id = #{category.id} where id=#{id}")
	public void update(Product p);
	
		
	@Delete("delete from product where id=#{id}")
	public void delete(Product p);
	
	
	@Insert("insert into product (name,price,quantity,description,c_id) values(#{name},#{price},#{quantity},#{description},#{category.id})")
	public void add(Product p);
	
	
	
}
